package com.rising.spring.main;


import com.rising.spring.bean.Apple;
import com.rising.spring.bean.Fruit;
import com.rising.spring.service.FruitService;
import com.rising.spring.service.impl.FruitServiceImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class SpringTest1 {
    public static void main(String[] args) {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        FruitService fruitService1 = (FruitService) ctx.getBean("fruitServiceImpl");
        FruitService fruitService2 = ctx.getBean(FruitServiceImpl.class);
        fruitService1.eatFruit();
        fruitService2.eatFruit();
        Fruit apple = ctx.getBean(Apple.class);
        System.out.println(apple);
        System.out.println("现在开始关闭容器！");
        ((ClassPathXmlApplicationContext) ctx).registerShutdownHook();
    }
}
